<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2017 the OpenProject Foundation (OPF)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.

OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2017 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

See doc/COPYRIGHT.rdoc for more details.

++#%>
<% html_title l(:label_administration), l(:label_enumerations) %>
<%= toolbar title: l(:label_enumerations) %>
<% Enumeration.descendants.each do |klass| %>
  <h3 class="-no-border"><%= l(klass::OptionName) %></h3>
  <% enumerations = klass.shared %>
  <% if enumerations.any? %>
    <div class="generic-table--container">
      <div class="generic-table--results-container">
        <table class="generic-table">
          <colgroup>
            <col highlight-col>
            <col highlight-col>
            <col highlight-col>
            <col highlight-col>
            <col>
          </colgroup>
          <thead>
            <tr>
              <th>
                <div class="generic-table--sort-header-outer">
                  <div class="generic-table--sort-header">
                    <span>
                      <%= Enumeration.human_attribute_name(:name) %>
                    </span>
                  </div>
                </div>
              </th>
              <th>
                <div class="generic-table--sort-header-outer" style="max-width:200px;">
                  <div class="generic-table--sort-header">
                    <span>
                      <%= Enumeration.human_attribute_name(:is_default) %>
                    </span>
                  </div>
                </div>
              </th>
              <th>
                <div class="generic-table--sort-header-outer" style="max-width:200px;">
                  <div class="generic-table--sort-header">
                    <span>
                      <%= Enumeration.human_attribute_name(:active) %>
                    </span>
                  </div>
                </div>
              </th>
              <th>
                <div class="generic-table--sort-header-outer" style="max-width:200px;">
                  <div class="generic-table--sort-header">
                    <span>
                      <%=l(:button_sort)%>
                    </span>
                  </div>
                </div>
              </th>
              <th style="max-width:200px;"></th>
            </tr>
          </thead>
          <% enumerations.each do |enumeration| %>
            <tr>
              <td><%= link_to h(enumeration), action: 'edit', id: enumeration %></td>
              <td style="width:200px;"><%= checked_image enumeration.is_default? %></td>
              <td style="width:200px;"><%= checked_image enumeration.active? %></td>
              <td style="width:200px;"><%= reorder_links('enumeration', {action: 'update', id: enumeration}, method: :put) %></td>
              <td class="buttons" style="width:200px;">
                <%= link_to l(:button_delete), { action: 'destroy', id: enumeration },
                    method: :delete,
                    data: { confirm: l(:text_are_you_sure) },
                    class: 'icon icon-delete' %>
              </td>
            </tr>
          <% end %>
        </table>
        
      </div>
    </div>
  <% end %>
  <div class="generic-table--action-buttons">
    <%= link_to new_enumeration_path(type: klass.name),
          { class: 'button -alt-highlight',
            aria: {label: t(:label_enumeration_new)},
            title: t(:label_enumeration_new)} do %>
      <i class="button--icon icon-add"></i>
      <span class="button--text"><%= l(:label_enumeration_value) %></span>
    <% end %>
  </div>

<% end %>
